package main

import (
	"log"

	"github.com/aurora-go/aurora"
)

type BaseResponse struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data"`
}

type UserParam struct {
	UserName string
}

func main() {
	web := aurora.Web

	web.Get("/", func() BaseResponse {
		//直接返回一个数据实例
		return BaseResponse{
			Code:    200,
			Message: "aurora start",
			Data:    "任意类型吧",
		}
	})

	web.Post("/", func(userParam UserParam) BaseResponse {
		log.Printf("前端传过来的用户名是", userParam.UserName)
		var dict map[string]string

		dict = make(map[string]string)

		dict["password"] = "string"
		dict["用户名"] = userParam.UserName

		//直接返回一个数据实例
		return BaseResponse{
			Code:    200,
			Message: "aurora start",
			Data:    dict,
		}
	})

	web.Get("/test", func() map[string]string {
		log.Printf("打印日志到控制台")
		//直接返回一个数据实例
		return map[string]string{"a": "aa"}
	})

	aurora.Run(web)
}
